package org.southyin.controller.cms_customer;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.southyin.commons.CommonsResp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "CustomerLogoutServlet", value = "/user/logout")
public class CustomerLogoutServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //销毁Session对象
        request.getSession().invalidate();
        CommonsResp resp = CommonsResp.success(200, "退出成功");
        response.getWriter().println(new ObjectMapper().writeValueAsString(resp));
    }
}
